package com.bootmybatisplus.controller;

import com.bootmybatisplus.entity.Score;
import com.bootmybatisplus.service.IScoreService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author huilin_rong
 * @date 2021/01/15
 */
@RequestMapping("/mp")
@RestController
public class ScoreController {

    @Resource
    private IScoreService iScoreService;

    @GetMapping("/saveOrUpdate")
    public Object saveOrUpdate(Integer id, String name, Integer score) {
        Score s = new Score(id, name, score);
        return iScoreService.saveOrUpdateScore(s);
    }

    @GetMapping("pageListScore")
    public Object pageListScore(Integer current, Integer size) {
        if (current == null) {
            current = 1;
        }
        if (size == null) {
            size = 10;
        }
        return iScoreService.pageListScore(current, size);
    }

}
